package com.crois.barrier.common.response;

import com.crois.barrier.common.exception.BarrierException;
import com.crois.barrier.common.exception.BarrierExceptionEnum;
import lombok.Data;

import java.util.List;

/**
 * @author Hou Ze Yu
 * @description
 * @date 2020/10/23
 */
@Data
public class BarrierDefaultResponse implements BarrierResponse<BarrierResponseEntity<?>> {

    public BarrierResponseEntity<Void> ok(){
        return new BarrierResponseEntity<>(BarrierResponseStatus.SUCCESS);
    }

    public BarrierResponseEntity<?> ok(Object data){
        BarrierResponseEntity<Object> doorResponse=new BarrierResponseEntity<>(BarrierResponseStatus.SUCCESS);
        doorResponse.setData(data);
        return doorResponse ;
    }
    public BarrierResponseEntity<List<?>> okList(List<?> list){
        BarrierResponseEntity<List<?>> doorResponse=new BarrierResponseEntity<>(BarrierResponseStatus.SUCCESS);
        doorResponse.setData(list);
        return doorResponse ;
    }
    public BarrierResponseEntity<Void> fail(){
        return new BarrierResponseEntity<>(BarrierResponseStatus.FAIL);
    }

    public BarrierResponseEntity<Void> fail(BarrierException barrierException){
        return new BarrierResponseEntity<Void>(barrierException.getMessage(),barrierException.getCode());
    }
    public BarrierResponseEntity<Void> fail(BarrierExceptionEnum barrierExceptionEnum){
        return new BarrierResponseEntity<Void>(barrierExceptionEnum.getMessage(),barrierExceptionEnum.getCode());
    }
}
